<template>
	<view class="container">
		<view class="showGoods">显示所有在线的商品</view>
		<Default
			:showflag="showflag"
			:type='4'
		></Default>
		<view class="goodsList" v-if="favList.length > 0">
			<view class="item" v-for="(item, index) in favList" :key='index' @click="goGoodsDetail(item.out_id)">
				<image :src="item.goods_master_image" mode=""></image>
				<view class="goodsMsg">
					<view class="goodsName">{{ item.goods_name }}</view>
					<view class="goodsSpec">常规版型 | 纯棉</view>
					<view class="goodsPrice">
						<view class="now">￥<text>{{ item.goods_price }}</text></view>
						<view class="old">￥254.00</view>
						<view class="qiang">已抢12345件</view>
					</view>
					<view class="storeName">李小二的店</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return{
				showflag: false,
				favList: [],
			}
		},
		onShow() {
			this.getFavList()
		},
		methods: {
			// 获取用户收藏列表
			getFavList() {
				var that = this
				this.$http.post({
					url: 'Mini/favorites/getFavoritesList',
					data: {
						is_type: 0
					}
				}).then(res => {
					// console.log(res)
					if (res.status) {
						that.favList = res.data.data
						if (that.favList.length > 0) {
							that.showflag = false
						} else {
							that.showflag = true
						}
						// console.log(that.favList)
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch(res => {
					// uni.showToast({
					// 	title: res.msg,
					// 	icon: 'none'
					// })
				})
			},
			//  跳转商品详情
			goGoodsDetail(id) {
				uni.navigateTo({
					url: `/other/goodsDetail/index?goods_id=${id}`
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.container{
		height: 100%;
		background-color: #EDEDED;
	}
	.showGoods{
		height: 100rpx;
		width: 100%;
		background-color: #fff;
		padding-left: 50rpx;
		box-sizing: border-box;
		line-height: 100rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #34C39E;
	}
	.item{
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		width: 100%;
		height: 268rpx;
		padding: 25rpx 30rpx;
		box-sizing: border-box;
		border-radius: 20rpx;
		background-color: #fff;
		margin: 10rpx 0;
		&>image{
			display: block;
			height: 218rpx;
			width: 218rpx;
			margin-right: 28rpx;
		}
		.goodsMsg{
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.goodsName{
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #494949;
			}
			.goodsSpec{
				font-size: 22rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
			}
			.goodsPrice{
				display: flex;
				flex-direction: row;
				justify-content: flex-start;
				align-items: flex-end;
				.now{
					font-size: 22rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					color: #F55519;
					&>text{
						font-size: 30rpx;
					}
				}
				.old{
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					text-decoration: line-through;
					color: #B8B8B8;
					margin-left: 27rpx;
				}
				.qiang{
					margin-left: auto;
					font-size: 22rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
			}
			.storeName{
				font-size: 22rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
			}
		}
	}


</style>
